package com.letv.whatslive.mysql.mybatis.pay;

import com.letv.ugc.common.database.mybatis.page.Page;
import com.letv.whatslive.model.mysql.pay.LehiActivity;
import com.letv.whatslive.model.mysql.pay.LehiActivityExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * Created by shenyue1 on 2016/8/2.
 */
@Component
public class LehiActivityDao {
    @Autowired
    private LehiActivityMapper lehiActivityMapper;
    public List<LehiActivity> selectAll(Map<String,Object> params,Integer pageSize,Integer pageNo){
        LehiActivityExample example = new LehiActivityExample();
        example.setOrderByClause("id desc");
        LehiActivityExample.Criteria criteria=example.createCriteria();
        if(params!=null&&!params.isEmpty()){
            if(params.get("title")!=null)
                criteria.andTitleLike((String)params.get("title"));
            if(params.get("type")!=null)
                criteria.andTypeEqualTo((Short)params.get("type"));
        }
        return lehiActivityMapper.selectByExample(example,new Page(pageNo, pageSize));
    }

    public void insert(LehiActivity lehiActivity){
        lehiActivityMapper.insertSelective(lehiActivity);
    }
    public int totalCount(Map<String,Object> params){
        return lehiActivityMapper.totalCount(params);
    }

}
